﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Lilium.Web.Mvc.State
{
	public interface IStateService
	{
        /// <summary>
        /// Returns name of the state property to represent it on client side.
        /// </summary>
        /// <param name="consumer"></param>
        /// <param name="propertyName"></param>
        /// <returns></returns>
        /// <remarks>
        /// StateParameterName is used to manipulate specific state parameters on client side,
        /// for example to create dropdown filters.
        /// </remarks>
        string GetStateParameterName(IStatefulObject consumer, string propertyName);

		bool PropertyLoaded(IStatefulObject consumer, string propertyName);

        void RegisterConsumer(IStatefulObject consumer, bool overrideExistentRegistration);

        /// <summary>
        /// Saves object state for the specified action into the route values dictionary.
        /// </summary>
        void SaveObjectState(IStatefulObject consumer, string actionName, IDictionary<string, object> routeValues);

        //TODO: is it obsoleted?
		void SaveObjectsState(IDictionary<string, object> routeValues);

		/// <summary>
		/// Serializes custom state value for specified consumer and creates corresponding key-value pair.
		/// </summary>
		/// <param name="state"></param>
		/// <param name="consumer"></param>
		/// <returns></returns>
		/// <remarks>
		/// Key value is based on consumer's key and may be formatted according service-specific rules.
		/// Value is the state object, converted to service-specific format for serialization purpose.
		/// </remarks>
        //TODO: why public?
		KeyValuePair<string, object> SerializeState(IStatefulObject consumer, object state);
	}
}